package com.jnu.mydiary.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.jnu.mydiary.R;
import com.jnu.mydiary.ui.shouye1.myBean;

import java.util.List;

public class beanAdapter  extends ArrayAdapter {


    private int ImageId;


    public beanAdapter(Context context, int ImageId, List<myBean> obj) {
        super(context,ImageId,obj);
        this.ImageId=ImageId;
    }

    @NonNull
    @Override
    public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        myBean mBean = (myBean) getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(ImageId,null);//这个是实例化一个我们自己写的界面Item
        TextView mDate=view.findViewById(R.id.home_item_tv_time);
        TextView mTitle=view.findViewById(R.id.home_item_tv_title);
        ImageView mWeather=view.findViewById(R.id.home_item_iv_weather);
        ImageView mMood=view.findViewById(R.id.home_item_iv_mood);
        mDate.setText(mBean.getDate());
        mTitle.setText(mBean.getTitle());
        mWeather.setImageResource(mBean.getwImageId());
        mMood.setImageResource(mBean.getmImageId());

        return view;
    }

}
